package com.zonekey.utils;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;

/**
 * Created by Administrator on 2019/6/18 0018.
 */
public class PropertiesUtil {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 读取springboot运行的application.properties配置字符串内容
     * @param configKey
     * @return
     */
    public static String get(String configKey) {
        Environment env = SpringUtil.getBean(Environment.class);
        String configValue = StringUtils.trim(env.getProperty(configKey));
        return configValue;
    }

    /**
     * 读取springboot运行的application.properties配置整数内容
     * @param configKey
     * @return
     */
    public static Integer getInt(String configKey) {
        return Integer.parseInt(get(configKey));
    }

}
